﻿<UserControl x:Class="UC.Login.CadastroDeUsuarioView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:baseValidator="clr-namespace:UC.BaseMVVM">
    <UserControl.Resources>
        <Style TargetType="{x:Type Label}">
            <Setter Property="Height" Value="28" />
        </Style>

        <Style x:Key="ResultadosDeValidacoesStyle"  TargetType="{x:Type baseValidator:ResultadosDeValicacao}">
            <Setter Property="Background" Value="Salmon" />
        </Style>


        <!-- Passar para o arquivo de template        -->


        <Style TargetType="{x:Type ToolTip}">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type ToolTip}">
                        <ListBox DisplayMemberPath="ErrorContent" ItemsSource="{TemplateBinding Content}" />
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <Style TargetType="{x:Type TextBox}">
            <Setter Property="Height" Value="28" />

            <Style.Triggers>
                <Trigger Property="IsMouseOver" Value="True">
                    <Setter Property="Background" Value="Yellow" />
                </Trigger>
                
                <Trigger Property="Validation.HasError" Value="True">
                    <Setter Property="ToolTip" Value="{Binding (Validation.Errors), RelativeSource={RelativeSource Self}}" />
                </Trigger>
            </Style.Triggers>
        </Style>

    </UserControl.Resources>

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition />
            <RowDefinition />
            <RowDefinition />
            <RowDefinition />
            <RowDefinition />
            <RowDefinition Height="*"/>
            <RowDefinition Height="*" />
            <RowDefinition Height="*" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="400" />
        </Grid.ColumnDefinitions>
        
        <Label Content="Nome de usuário:" Grid.Row="0" Grid.Column="0" />
        <TextBox Text="{Binding CadastroDeUsuarioModel.NomeDeUsuario, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" Grid.Row="0" Grid.Column="1" />

        <Label Content="Email:" Grid.Row="1" Grid.Column="0" />
        <TextBox Text="{Binding CadastroDeUsuarioModel.Email, UpdateSourceTrigger=Default, Mode=TwoWay}" Grid.Row="1" Grid.Column="1" />

        <Label Content="Repetir Email:" Grid.Row="2" Grid.Column="0" />
        <TextBox Text="{Binding CadastroDeUsuarioModel.RepeticaoEmail, ValidatesOnNotifyDataErrors=True, UpdateSourceTrigger=Default, Mode=TwoWay}" Grid.Row="2" Grid.Column="1" IsReadOnlyCaretVisible="True" />

        <Button Content="Confirmar" Command="{Binding ConfirmarCommand}" Grid.Row="3" Grid.ColumnSpan="2" Width="100" />

        <Label Content="Tipo de Endereço:" Grid.Row="4" Grid.Column="0" />
        <ListView Grid.Row="4" Grid.Column="1" >
            <StackPanel>
                <TextBox Text="{Binding CadastroDeUsuarioModel.EnderecoResidencial, ValidatesOnNotifyDataErrors=True, UpdateSourceTrigger=Default, Mode=TwoWay}" />
                <TextBox Text="{Binding CadastroDeUsuarioModel.EnderecoComercial, ValidatesOnNotifyDataErrors=True, UpdateSourceTrigger=Default, Mode=TwoWay}" />
            </StackPanel>
        </ListView>

        <Label Content="Validações:" Grid.Row="5" Grid.Column="0" HorizontalAlignment="Right" VerticalAlignment="Top" />
        <baseValidator:ValidacaoControl EstiloDaLista="{StaticResource ResultadosDeValidacoesStyle}" Grid.Row="5" Grid.Column="1" Background="PowderBlue" />

    </Grid>
</UserControl>
